Conway's game of life.
Published:
Last edited:
p5.js
I would like to start this post by giving thanks to the p5.js library for making this possible as well as the p5-svelte API for making p5.js work with svelte to be very simple with the least hastle I’ve has with any other 3d / graphics in Javascript.
What is Conways game of life?
Conways game of life or just ‘life’ is a cellular automaton that is a zero player game / simulation. The simulation consists of a grid containing “cells” - these cells can be in one of two states: ‘alive’ or ‘dead’, these cells are then subjected to 3 rules that define the whole game:
- Any 'alive' cell with less than two neighbours dies.
- Any 'alive' cell with two or three neighbours lives on to the next generation.
- Any 'alive' cell with more than three live neighbours dies.
- Any 'dead' cell with exactly three live neighbours becomes an 'alive' cell.
Simulaton of Conway’s game of life
Below should be a simulation of Conway’s game of life:
(clicking anywhere resets the canvas)